const { htmlToDocx } = require('../dist/lib/index.js');

async function testDetailedImage() {
  const html = `
    <img style="display: inline-block; height: 2px;" src="" width="100%" data-mce-style="display: inline-block; height: 2px;"/>
  `;

  try {
    console.log('开始转换 HTML 到 DOCX...');
    const result = await htmlToDocx(html);
    console.log('转换成功！');
    console.log('警告信息:', result.warnings);

    // 检查文档内容
    const documentWrapper = result.document.documentWrapper;
    const document = documentWrapper.document;
    const body = document.body;

    body.root.forEach((item) => {
      if (item.constructor.name === 'Paragraph') {
        item.root.forEach((rootItem) => {
          if (rootItem.constructor.name === 'ImageRun') {
            console.log('找到图片运行！');
            console.log('图片运行属性:', Object.keys(rootItem));

            if (rootItem.transformation) {
              console.log('图片变换:', rootItem.transformation);
            }

            if (rootItem.root) {
              rootItem.root.forEach((rootChild) => {
                if (rootChild.constructor.name === 'Drawing') {
                  console.log('Drawing 元素 root 长度:', rootChild.root.length);
                  rootChild.root.forEach((drawingChild) => {
                    console.log('Drawing 子元素:', drawingChild.constructor.name);
                    if (drawingChild.constructor.name === 'BuilderElement') {
                      console.log('BuilderElement 属性:', Object.keys(drawingChild));
                      if (drawingChild.root) {
                        console.log('BuilderElement root 长度:', drawingChild.root.length);
                        drawingChild.root.forEach((builderChild, index) => {
                          console.log(`  Builder 子元素 ${index}:`, builderChild.constructor.name);
                          console.log(`  Builder 子元素 ${index} 属性:`, Object.keys(builderChild));

                          if (builderChild.constructor.name === 'DocProperties') {
                            console.log('  找到 DocProperties！');
                            if (builderChild.root) {
                              console.log('  DocProperties root 长度:', builderChild.root.length);
                              builderChild.root.forEach((docProp, docIndex) => {
                                console.log(`    DocProperties 子元素 ${docIndex}:`, docProp.constructor.name);
                                console.log(`    DocProperties 子元素 ${docIndex} 属性:`, Object.keys(docProp));
                              });
                            }
                          }
                        });
                      }
                    }
                  });
                }
              });
            }
          }
        });
      }
    });
  } catch (error) {
    console.error('转换失败:', error);
  }
}

testDetailedImage();
